<template>
    <el-table :data="tableData" fit border size="mini" :height='height'>
        <el-table-column prop="orderNo" label="订单号"></el-table-column>
        <el-table-column prop="id" label="UID"></el-table-column>
        <el-table-column prop="payTime" label="创建时间" sortable></el-table-column>
        <el-table-column prop="amount" label="订单金额"></el-table-column>
        <el-table-column prop="source" label="订单来源">
            <template slot-scope="scope">
                <span>{{scope.row.source=='1'?'淘宝':scope.row.source=='0'?'微盟':'其他'}}</span>
            </template>
        </el-table-column>
        <el-table-column prop="goodType" label="类型" >
            <template slot-scope="scope">
                <span>{{scope.row.goodType=='0'?'服务产品':'无'}}</span>
            </template>
        </el-table-column>
        <el-table-column prop="payType" label="订单状态">
            <template slot-scope="scope">
                <span>{{scope.row.status=='1'?'交易成功':'交易关闭'}}</span>
            </template>
        </el-table-column>
        <!-- <el-table-column label="操作" width="180">
        <template slot-scope="scope">   暂时不可用
            <el-button type="text" size="small" @click="editUser(scope.row)">退款</el-button>
            <el-button type="text" size="small" @click="del(scope.row)">关闭交易</el-button>
        </template> 
        </el-table-column>-->
    </el-table>
</template>
<script>
import { request } from "../../assets/request.js";
export default {
    data(){
        return{
            tableData: [
                {
                    orderNum: "201812160001",
                    userId: "2015002102",
                    orderPrice: "￥299",
                    orderSource: "微盟",
                    dataTime: "2018-12-01 14:36",
                    orderType:'服务产品',
                    orderState: '待付款',
                }
            ],
            obj:{
                size:20,
                page:1,
            },
            height: window.innerHeight - 283
        }
    },
    created(){
        this.selectList(this.obj)
        this.$root.$on('financeList',data=>{
            this.obj=data
            console.log(this.obj)
            this.selectList(this.obj)
        })
    },
    methods:{
        editUser(row){

        },
        closeDeal(row){
            let that=this
            request.delAlert({
                name:'关闭该订单',
                that,
                fn(obj){
                    that.$message(obj)
                }
            })
        },
        selectList(obj){
            //列表请求
            let url = "transaction";
            let that = this; //解决this指向问题
            request.ajaxGet({
                url,
                that,
                params: obj,
                fn(res) {
                    // console.log(res)
                    that.tableData=res.list
                    that.$root.$emit("finance",res.total)
                }
            })
        }
    }
}
</script>
<style lang="less" scoped>

</style>
